package com.liu.yubi.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.rholder.retry.RetryException;
import com.liu.yubi.common.DeleteRequest;
import com.liu.yubi.model.dto.chart.ChartQueryRequest;
import com.liu.yubi.model.dto.chart.ChartRegenRequest;
import com.liu.yubi.model.dto.chart.ChartUpdateRequest;
import com.liu.yubi.model.dto.chart.GenChartByAiRequest;
import com.liu.yubi.model.entity.Chart;
import com.baomidou.mybatisplus.extension.service.IService;
import com.liu.yubi.model.entity.User;
import com.liu.yubi.model.vo.BiResponse;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.concurrent.ExecutionException;

/**
* 针对表【chart(图表信息表)】的数据库操作Service
*  2025-05-24 16:44:54
*/
public interface ChartService extends IService<Chart> {

    /**
     * 智能化AI分析处理
     */
     BiResponse genChartByAi(MultipartFile file, GenChartByAiRequest aiRequest, User user);

    /**
     * 智能化AI分析处理（线程池）
     */
    Long genByAiAsync(MultipartFile file, GenChartByAiRequest aiRequest, User user);

    /**
     * 智能化分析处理（Mq消息队列）
     */
    Long genByAiMq(MultipartFile file, GenChartByAiRequest aiRequest, User user) throws ExecutionException, RetryException;

    /**
     * 删除图表
     */
    Boolean delete(DeleteRequest deleteRequest, HttpServletRequest request);

    /**
     * 更新图表数据
     */
    Boolean updateChart(ChartUpdateRequest chartUpdateRequest);

    /**
     * 查询信息绑定
     * QueryWrapper
     */
    QueryWrapper<Chart> getQueryWrapper(ChartQueryRequest chartQueryRequest);

    /**
     分页获取图表列表（仅管理员）
     */
    Page<Chart> listChartByPage(ChartQueryRequest chartQueryRequest);

    /**
     * 更新数据库异常数据
     */
    void handleErrorChart(Long chartId,String message);

    /**
     * 重新生成图表
     */
    BiResponse regenChart(ChartRegenRequest regenRequest, HttpServletRequest request);

    /**
     * 重新修改图表(Admin)
     */
    Boolean regenChartByAsyncMqAdmin(ChartRegenRequest regenRequest, HttpServletRequest request);
}
